let prom_types = [
  {"name": "单一促销","type": 1,code: "sigle_promotion"},
  {"name": "满额促销","type": 3,code: "mane_promotion"},
  {"name": "秒杀","type": 4,code: "skill_promotion"},
  {"name": "满量促销","type": 2,code: "sigle_promotion"},
  {"name": "赠送类促销","type": 5,code: "gift_promotion"},
  {"name": "组合促销","type": 6,code: "complex_promotion"},
  {"name": "单品X件优惠","type": 7,code: "sigle_promotion_1"},
  {"name": "换购","type": 8,code: "increase_promotion"},
  {"name": "预售","type": 9,code: "presell_promotion"},
]

let front_prom_types = [
  {"name": "请选择","type": null,code: "ALL"},
  {"name": "特价促销","type": '1',code: "sigle_front_prom_type"},
  {"name": "折扣促销","type": '2',code: "sigle_front_prom_type"},
  {"name": "直降促销","type": '3',code: "sigle_front_prom_type"},
  {"name": "秒杀","type": '10',code: "skill_front_prom_type"},
  {"name": "满量减","type": '4',code: "sigle_front_prom_type_ml"},
  {"name": "满量折","type": '5',code: "sigle_front_prom_type_ml"},
  {"name": "满额赠送","type": '8',code: "gift_front_prom_type"},
  {"name": "满量赠送","type": '9',code: "gift_front_prom_type"},
  {"name": "第X件Y折","type": '12',code: "complex_front_prom_type"},
  {"name": "第X件Y元","type": '13',code: "complex_front_prom_type"},
  {"name": "满X件Y折","type": '14',code: "complex_front_prom_type"},
  {"name": "满额减","type": '6',code: "full_front_prom_type"},
  {"name": "满额折","type": '7',code: "full_front_prom_type"},
  // {"name": "尾款结算","type": '17',code: "presell_front_prom_type"},
  {"name": "一口价","type": '18',code: "presell_front_prom_type"},
  {"name": "满额减运费","type": '19',code: "full_front_prom_type"},
  {"name": "满金额换购","type": '15',code: "increase_front_prom_type"},
  {"name": "买商品换购","type": '16',code: "increase_front_prom_type"},
  {"name": "we2000","type": '1',code: "payment_reduction"},
  {"name": "微信支付","type": '2',code: "payment_reduction"},
  {"name": "微众卡","type": '3',code: "payment_reduction"},
  {"name": "企业购","type": '4',code: "payment_reduction"},
]

let full_prom_types = [
  {"name": "满额减","type": 6,code: "full_front_prom_type"},
  {"name": "满额折","type": 7,code: "full_front_prom_type"},
  {"name": "满额减运费","type": 19,code: "full_front_prom_type"},
]

let chanel_codes = [
  {"name": "BBC","code": "110001"}
]


let singleFrontPromTypesRadio = [
  {"name": "特价促销","code": 1},
  {"name": "折扣促销","code": 2},
  {"name": "直降促销","code": 3}
]

let chanelCodesRadio = [
  //B2C  B2B  O&O
  {"name": "子平台1","code": '110001'},
  {"name": "子平台2","code": '110002'},
  {"name": "子平台3","code": '110003'},
  {"name": "子平台4","code": '110004'},
]

let proPlatformRadio = [
  {"name": "APP端","code": '1'},
  {"name": "PC端","code": '2'},
  {"name": "微信","code": '3'}
]

let proUserTypeRadio = [
  //改成了单选框，不要再注释掉了
  {"name": "全部","code": "0"},
  {"name": "新用户","code": "1"},
  {"name": "老用户","code": "2"}
]

// 拼团新老用户
let proUserTypeGroupRadio = [
  {"name": "新用户","code": "1"},
  {"name": "老用户","code": "2"}
]

// 拼团开团活动对象
let customerLimitRadio = [
  {"name": "全部","code": "0"},
  {"name": "新用户","code": '1'},
  {"name": "老用户","code": '2'}
]

// 拼团参团活动对象
let offeredCustomerLimitRadio = [
  {"name": "全部","code": "0"},
  {"name": "新用户","code": '1'},
  {"name": "老用户","code": '2'}
]

let proMemberTypeRadio = [
  {"name": "普通会员","code": '1'}
]

let proMemberLevelRadio = [
  {"name": "注册会员","code": '1'},
  {"name": "VIP会员","code": '2'},
]



function promTypeConverter (type) {
  let name = '';
  prom_types.map(function(value,index,array){
    if(value.type == type){
      name = value.name;
    }
  });
  return name;
}


function frontPromTypeConverter (type) {
  let item = front_prom_types.find(function (item, index) {
    return item.type == type
  })
  return typeof(item)=="undefined" ? "null" : item.name;
}

function frontPromTypeConverterFull (type) {
  let item = full_prom_types.find(function (item, index) {
    return item.type == type
  })
  return typeof(item)=="undefined" ? "null" : item.name;
}

function channelCodeConverter (code) {
  let item = chanel_codes.find(function (item, index) {
    return item.code == code
  })
  return typeof(item)=="undefined" ? "BBC" : item.name;
}

function proPlatformConverter (code) {
  let item = proPlatformRadio.find(function (item, index) {
    return item.code == code
  })
  return typeof(item)=="undefined" ? "null" : item.name;
}

function proUserTypeConverter (code) {
  let item = proUserTypeRadio.find(function (item, index) {
    return item.code == code
  })
  return typeof(item)=="undefined" ? "null" : item.name;
}

function proUserTypeGroupConverter (code) {
  let item = proUserTypeGroupRadio.find(function (item, index) {
    return item.code == code
  })
  return typeof(item)=="undefined" ? "null" : item.name;
}

function customerLimitConverter (code) {
  let item = customerLimitRadio.find(function (item, index) {
    return item.code == code
  })
  return typeof(item)=="undefined" ? "null" : item.name;
}

function offeredCustomerLimitConverter (code) {
  let item = offeredCustomerLimitRadio.find(function (item, index) {
    return item.code == code
  })
  return typeof(item)=="undefined" ? "null" : item.name;
}

function proMemberTypeConverter (code) {
  let item = proMemberTypeRadio.find(function (item, index) {
    return item.code == code
  })
  return typeof(item)=="undefined" ? "null" : item.name;
}

function proMemberLevelConverter (code) {
  let item = proMemberLevelRadio.find(function (item, index) {
    return item.code == code
  })
  return typeof(item)=="undefined" ? "null" : item.name;
}

module.exports = {
  prom_types,
  front_prom_types,
  full_prom_types,
  chanel_codes,
  promTypeConverter,
  frontPromTypeConverter,
  frontPromTypeConverterFull,
  channelCodeConverter,
  proPlatformConverter,
  proUserTypeConverter,
  proMemberTypeConverter,
  proMemberLevelConverter,

  singleFrontPromTypesRadio,
  chanelCodesRadio,
  proPlatformRadio,
  proUserTypeRadio,
  proUserTypeGroupRadio,
  customerLimitRadio,
  offeredCustomerLimitRadio,
  proMemberTypeRadio,
  proMemberLevelRadio,

}
